﻿/**
* @description  Events specifically for tween animations.
*/
package com.foed.events {

	import flash.events.Event;

	import com.foed.animation.Animator;
	
	public class TweenEvent extends Event {
		
		public static const START:String = "tweenEnd";
		public static const END:String = "tweenStart";
		public static const CHANGE:String = "tweenChange";

		private var _animator:Animator;
		
		/**
		* @description  Constructor.
		*
		* @param  pType  The name if the event.
		* @param  pAnimator  The animator controlling the tween.
		* @param  pBubbles  Whether the event bubbles up through the display list.
		* @param  pCancelable  Whether the event can be canceled as it bubbles.
		*/
		public function TweenEvent(
			pType:String,
			pAnimator:Animator,
			pBubbles:Boolean=false,
			pCancelable:Boolean=false
		) {
			super(pType, pCancelable, pBubbles);
			_animator = pAnimator;
		}

		/**
		* @description  Returns a copy of the event instance.
		*
		* @returns  A copy of the event.
		*/
		override public function clone():Event {
			return new TweenEvent(type, _animator, bubbles, cancelable);
		}

		/**
		* @description  Returns the animator controlling the tween.
		*
		* @returns  The Animator instance that originally fired the event.
		*/
		public function get animator():Animator {
			return _animator;
		}

	}
	
}